home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 August: Tool Chest / Dev.CD Aug 94.toast / New System Software Extensions / OpenDoc A6 / OpenDoc Parts Framework / OPF / OS / FWGraphx / Include / FWBmpShp.h < prev    next >
Encoding:
Text File  |  1994-04-21  |  5.3 KB  |  183 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWBmpShp.h
  4. //    Release Version:    $ 1.0d1 $
  5. //
  6. //    Creation Date:        4/11/94
  7. //
  8. //    Copyright:    © 1994 by Apple Computer, Inc., all rights reserved.
  9. //
  10. //    Work to do 
  11. //        - Add GWorld flags to FW_SBitmap for Mac users 
  12. //
  13. //========================================================================================
  14.  
  15. #ifndef FWBMPSHP_H
  16. #define FWBMPSHP_H
  17.  
  18. #ifndef FWSHAPE_H
  19. #include "FWShape.h"
  20. #endif
  21.  
  22. #ifndef FWBNDSHP_H
  23. #include "FWBndShp.h"
  24. #endif
  25.  
  26. // ----- Macintosh Includes -----
  27.  
  28. #if defined(FW_BUILD_MAC) && !defined(__QDOFFSCREEN__)
  29. #include <QDOffScreen.h>
  30. #endif
  31.  
  32. //========================================================================================
  33. //    •• Forward Declarations
  34. //========================================================================================
  35.  
  36. class FW_CGraphicContext;
  37. class FW_CBitmapShapeRep;
  38. class FW_CPictShape;
  39.  
  40. //========================================================================================
  41. //    •• struct FW_SBitmapInfo
  42. //========================================================================================
  43.  
  44. struct FW_SBitmapInfo
  45. {
  46.     short     width; 
  47.     short     height;
  48.     short    rowBytes;
  49.     short     pixelSize;        // 1, 2, 4, 8, 16 or 32
  50. };
  51.  
  52. //========================================================================================
  53. //    •• CLASS FW_CBitmapShape
  54. //========================================================================================
  55.  
  56. class FW_CBitmapShape : public FW_CShape
  57. {
  58. //----------------------------------------------------------------------------------------
  59. //    • Constructors
  60. //
  61. public:
  62.     FW_CBitmapShape();
  63.     FW_CBitmapShape(short width, short height, short pixelSize, const FW_CRect& rect = FW_kZeroRect);
  64.     FW_CBitmapShape(char* image, short width, short height, short rowbytes, short pixelSize, const FW_CRect& rect = FW_kZeroRect);
  65.     
  66.     FW_CBitmapShape(const FW_CBitmapShape& other);
  67.     FW_CBitmapShape(FW_CBitmapShapeRep* rep);
  68.  
  69.     FW_CBitmapShape(FW_PlatformPict platformPicture, const FW_CRect& rect = FW_kZeroRect);
  70.  
  71. //----------------------------------------------------------------------------------------
  72. //    • Operators
  73. //
  74. public:
  75.     FW_CBitmapShape& operator=(const FW_CBitmapShape& other);    
  76.     FW_CBitmapShape& operator=(FW_CBitmapShapeRep* other);    
  77.     FW_CBitmapShapeRep* operator->() const
  78.                 {return (FW_CBitmapShapeRep*)GetRep();}
  79.  
  80. //----------------------------------------------------------------------------------------
  81. //    • Conversion
  82. //
  83. public:
  84.     operator FW_CPictShape() const;
  85. };
  86.  
  87. //========================================================================================
  88. //    •• class FW_CBitmapShapeRep
  89. //========================================================================================
  90.  
  91. class FW_CBitmapShapeRep : public FW_CBoundedShapeRep
  92. {
  93.     friend class FW_CBitmapShape;
  94.     
  95. //----------------------------------------------------------------------------------------
  96. //    • Constructors/Destructors
  97. //
  98. protected:
  99.     FW_CBitmapShapeRep();
  100.     FW_CBitmapShapeRep(char* image, 
  101.                         short width, short height, 
  102.                         short rowbytes, short pixelSize, 
  103.                         const FW_CRect& rect);
  104.  
  105.     FW_CBitmapShapeRep(FW_PlatformPict platformPicture, const FW_CRect& rect);
  106.     
  107.     virtual ~FW_CBitmapShapeRep();
  108.     
  109. //---------------------------------------------------------------------------------------
  110. //    • Inherited API
  111. //
  112. public:
  113.     // ----- Hit Testing -----
  114.     virtual FW_HitTestPart HitTest(const FW_CPoint& test) const;
  115.  
  116.     // ----- Rendering -----
  117.     virtual void         Draw(FW_CGraphicContext* graphicContext);
  118.     
  119.     // ----- Default shape -----
  120.     virtual void         SetAsDefault() const;
  121.  
  122.     // ----- Stream -----
  123.     virtual void    Flatten(FW_CWritableStream& stream);
  124.     virtual void    Unflatten(FW_CReadableStream& stream);
  125.  
  126. //---------------------------------------------------------------------------------------
  127. //    • New API
  128. //
  129. public:
  130.     FW_CBitmapShape        Copy() const;
  131.     
  132.     long                GetPixel(short x, short y) const;
  133.     long                GetPixel(short x, short y, FW_CColor& color) const;
  134.     
  135.     void                SetPixel(short x, short y, long index);
  136.     void                SetPixel(short x, short y, const FW_CColor& color);
  137.     
  138.     void                GetBitmapInfo(short& width, short& height, 
  139.                                         short& rowBytes, short& pixelSize) const;                
  140.     void                ChangeBitmap(char* image, 
  141.                                     short width, short height, 
  142.                                     short rowBytes, short pixelSize);
  143.  
  144.     FW_CBitmapShape     GetBitmapParts(const FW_CRect& bounds);
  145.     
  146.     void                 SetBitmapParts(const FW_CBitmapShape& bitmapShape, const FW_SPlatformRect& bounds);
  147.     void                SetBitmapParts(FW_PlatformPict platformPicture, const FW_SPlatformRect& bounds);
  148.  
  149.     void                CopyPixels(const FW_CBitmapShape& dstShape, 
  150.                                     const FW_SPlatformRect& srcRect, 
  151.                                     const FW_SPlatformRect& dstRect);
  152.     
  153. #ifdef FW_BUILD_MAC
  154. protected:
  155.     GWorldPtr            GetMacGWorld() const
  156.                             {return fMacGWorld;}
  157. private:    
  158.     void                NewGWorld(short width, short height, short pixelSize); 
  159.     void                 MacSetImage(char* image, short rowbytes); 
  160.     void                 MacSetImage(PicHandle picture, const FW_SPlatformRect& dstRect); 
  161.     PixMapHandle        LockPixels();
  162. #endif
  163.  
  164. private:
  165.     void                ConvertToPict(FW_CPictShape& pictShape);
  166.     
  167. //---------------------------------------------------------------------------------------
  168. //    • Data Member
  169. //
  170. private:
  171.     short                fHeight;
  172.     short                fWidth;
  173.     
  174. #ifdef FW_BUILD_MAC
  175.     short                fInitialPixelSize;
  176.     GWorldPtr            fMacGWorld;
  177. #endif
  178.  
  179. #ifdef FW_BUILD_WIN
  180. #endif
  181. };
  182.                 
  183. #endif